<?php
$goodId="";
if (getParameter("goodId")!=null)	$goodId=getParameter("goodId");
$search="";
if (getParameter("search")!=null)	$search=getParameter("search");
if ($goodId=="" && $search=="true") {

?>
<div class="announcementsTitle"><?php echo $text_search_results; ?></div> 
<div  class="homeTabs">
 <?php
 if (getParameter("start")!=null) $start=getParameter("start"); else $start=0;
if (!getParameter("start")!=null) {

if (strpos(curPageURI(),"?")!=false)
  $separator = "&";
  else
   $separator = "?";
// echo "<script>location.href='".curPageURI().$separator."start=0"."';</script>";
//header("Location: ".curPageURI().$separator."start=0");
  $start=0;
}

$step=3;

//$stop=$start+$step-1;
$whereCity="";
if (getParameter("cityId")!=null && getParameter("cityId")!="none") { $whereCity=" and goods.cityId='".getParameter("cityId")."' ";}

$wherePrice="";
if (getParameter("price_min")!=null) {
	$wherePrice=" and goods.price Between ".getParameter("price_min")." and ".getParameter("price_max");
}

$whereRooms="";
if (getParameter("rooms_min")!=null) {
	$whereRooms=" and goods.rooms Between ".getParameter("rooms_min")." and ".getParameter("rooms_max");
}

$whereSurface="";
if (getParameter("surface_min")!=null ) {
	$whereSurface=" and goods.surface Between ".getParameter("surface_min")." and ".getParameter("surface_max");
}


$where="FROM immo_gallery gallery,immo_goods goods,portal_quartier quartier,portal_cities cities,immo_operationtype operationtype  WHERE  goods.operationtypeId = operationtype.id and goods.id = gallery.goodId and quartier.id = goods.quartierId and cities.id = goods.cityId and  gallery.showHome = 'Y' and goods.agencyId=".$agencyId." ".$whereCity.$wherePrice.$whereRooms.$whereSurface."  Order By goods.id";
$sSql="Select Count(*) as count ".$where;
Portal_log($sSql);
$rs=$GLOBALS["conn"]->Execute($sSql);
if (!$rs->EOF) $count=$rs->fields["count"]; else $count=0;
$sSql= "Select goods.id As id, quartier.lib_".$lt." As quartier,  cities.lib_".$lt." As city,  goods.*, operationtype.lib_".$lang." As operation,  gallery.picture ".$where." LIMIT ".$start.",".$step."" ;
Portal_log($sSql);
      $rs=$GLOBALS["conn"]->Execute($sSql);
      if ($count>0) {
	  ?>
	  <table width="100%">
	  <?php

 while ( !$rs->EOF)  { 
		  ?>
	
		  <tr >
		  <td>
		  <div  class="homeTabsRow" style="display: block;"> 
<div class="imageContainer"> 
<img class="image" src = "../immo/pictures/<?php echo $rs->fields["picture"]; ?>"  height = "187px" width="249px"/>
</div> <div class="textContainer">


<a href="<?php echo createUrl("goodId",$rs->fields["id"]); ?>">
<div class="headline"><?php echo $rs->fields["title_".$LANG]; ?></div></a> 
<div class="title"><?php echo $rs->fields["operation"]; ?> : <?php echo $rs->fields["city"]; ?> / <?php echo $rs->fields["quartier"]; ?> Réf :<?php echo $rs->fields["reference"]; ?></div> 
<div class="description"><?php echo $rs->fields["description_".$LANG]; ?>

<br/>
<?php echo $text_price; ?> : <?php echo $rs->fields["price"]; ?> <?php echo $text_dhs; ?> / <?php echo $rs->fields["price"]*11; ?> â‚¬ (<?php echo $text_around; ?>)


</div>


<div class="tools_homeContent"> 
<table width="100%" height="26px"> <tbody>
<tr valign="top"> 
<td> <img src="./theme/facebook.png"><span> <a onclick="facebookShare('Ø±Ø¦ÙŠØ³ Ø§Ù„Ù…ÙƒØªØ¨ Ø§Ù„ÙˆØ·Ù†ÙŠ Ø§Ù„Ø³ÙŠØ¯ Ø­Ø³Ù† Ø¨Ù†Ø¹Ø¯ÙŠ','/ar/displayArticle?26542/ARTICLETEMPLATE');"><?php echo $text_facebookShare; ?></a> </span> </td>
 <td> <img src="./theme/tweet.png"><span> <a onclick="twitterShare('Ø±Ø¦ÙŠØ³ Ø§Ù„Ù…ÙƒØªØ¨ Ø§Ù„ÙˆØ·Ù†ÙŠ Ø§Ù„Ø³ÙŠØ¯ Ø­Ø³Ù† Ø¨Ù†Ø¹Ø¯ÙŠ','/ar/displayArticle?26542/ARTICLETEMPLATE');"><?php echo $text_tweeterShare; ?></a> </span> </td> 
<td> <img src="./theme/google.png"><span> <a onclick="twitterShare('Ø±Ø¦ÙŠØ³ Ø§Ù„Ù…ÙƒØªØ¨ Ø§Ù„ÙˆØ·Ù†ÙŠ Ø§Ù„Ø³ÙŠØ¯ Ø­Ø³Ù† Ø¨Ù†Ø¹Ø¯ÙŠ','/ar/displayArticle?26542/ARTICLETEMPLATE');"><?php echo $text_googleShare; ?></a> </span> </td> 
		</tr> </tbody></table> </div>


</td>

</tr>



				  <?php
		  $rs->MoveNext();    
		  }
		  
		  $pageUri=addParameter("start",$start);
	$next_url=str_replace("start=".$start,"start=".($start+$step),$pageUri);
	if ($start>=$step) $previous_url=str_replace("start=".$start,"start=".($start-$step),$pageUri);	

	
?>
</table>
<table dir="rtl" width="90%" >
<tr>
<?php if ($dir=="rtl") { ?><td width="80%"></td><?php } ?>
<?php if (($count-($start+$step))>0) { ?><td><a href="<?php echo $next_url; ?>"><img src="./images/next.png" title="Suivant"/></a></td><?php } ?>
<?php if ($start) { ?><td><a href="<?php echo $previous_url; ?>"><img src="./images/prev.png" title="Précedent"/></a></td> <?php } ?>
<?php if ($dir=="ltr") { ?><td width="80%"></td><?php } ?>
</tr>
</table>
<?php }else{?>

<?php echo $text_search_empty;?><br/>

  <?php } 
  
  if ($search=="true"){
		?>
		<a href="<?php echo createUrl("search",""); ?>"><?php echo $text_search_again; ?></a>
		<?php }?>
  </div>
  <?php } ?>
  
  